#ifndef _CANARY2_CORO_FUTURE_PRIOMISE_CONCEPTS_H_
#define _CANARY2_CORO_FUTURE_PRIOMISE_CONCEPTS_H_

#include "../util/coro_error.h"
#include <concepts>
#include <coroutine>
#include <type_traits>

namespace wilson::coro
{
    template<typename P>
    concept value_promise = requires(P p)
    {
        p.set_value(::std::declval<typename P::value_type>());
    };

    template<typename P>
    concept void_promise = requires(P p)
    {
        p.set_value();
    };

    template<typename Aw>
    concept awaitable = requires(Aw a)
    {
        { a.await_ready()  } -> ::std::same_as<bool>;
        a.await_suspend(::std::declval<::std::coroutine_handle<>>());
        { a.await_resume() } -> ::std::same_as<typename Aw::value_type>;
    };

    template<typename F>
    concept future = requires(F f)
    {
        { f.get() } -> awaitable;
    };
}

#endif
